#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=1e5+2;
int t,n,m,l,V;
int d,a,v,p[N],a3[N],b3[N];//a3: backward spots can noticed it
int cn[N];

int cal_s(int v0,int vt,int a){
    int ret=int((vt*vt-v0*v0)*1.0/2/a);
    if((vt*vt-v0*v0)%(2*a)==0)return ret;
    return ret+1;
}

int upper(int x){
    int l=1,r=m;
    while(l<=r){
        int mid=(l+r)/2;
        if(p[mid]>x)r=mid-1;
        if(p[mid]<=x)l=mid+1;
    }
    return l;
}

int lower(int x){
    int l=1,r=m;
    while(l<=r){
        int mid=(l+r)/2;
        if(p[mid]>=x)r=mid-1;
        if(p[mid]<x)l=mid+1;
    }
    return l;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>V;
        int ans1=0,ans2=0;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d,&v,&a);
            if(v>V && a>=0)a3[i]=d;
            else if(v>V && a<0)b3[i]=d+cal_s(v,V,a),a3[i]=d-1;
            else if(v==V && a>0)a3[i]=d;
            else if(v<V && a>0)a3[i]=d+cal_s(v,V,a)-1;
        }
        for(int i=1;i<=m;i++)scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            if(a3[i]){
                int ind=upper(a3[i]);
                if(!b3[i]){
                    cn[m]+=m-ind+1;
                    ans1++;
                }
                else if(p[ind]<b3[i]){
                    int y=lower(b3[i]);
                    cn[y]+=y-ind+1;
                    ans1++;
                }
            }
        }
        for(int i=1;i<=m;i++){
            if(cn[i]-cn[i-1]!=ans1)ans2++;
        }
        cout<<ans1<<' '<<ans2<<endl;
    }
    return 0;
}
